home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / term-Source.lha / termOldConfig.c < prev    next >
C/C++ Source or Header  |  1995-06-19  |  16KB  |  749 lines

  1. /*
  2. **    termOldConfig.c
  3. **
  4. **    Old configuration processing routines
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. struct OldSerialSettings
  13. {
  14.     ULONG    BaudRate;
  15.     ULONG    BreakLength;
  16.     ULONG    SerialBufferSize;
  17.  
  18.     UBYTE    SerialDevice[256];
  19.     LONG    UnitNumber;
  20.  
  21.     BYTE    BitsPerChar;
  22.     BYTE    Parity;
  23.     BYTE    StopBits;
  24.     BYTE    HandshakingProtocol;
  25.     BYTE    Duplex;
  26.  
  27.     BYTE    xONxOFF;
  28.     BYTE    HighSpeed;
  29.     BYTE    Shared;
  30.     BYTE    StripBit8;
  31.     BYTE    CheckCarrier;
  32.     BYTE    PassThrough;
  33. };
  34.  
  35. struct OldModemSettings
  36. {
  37.     UBYTE    ModemInit[80];
  38.     UBYTE     ModemExit[80];
  39.     UBYTE     ModemHangup[80];
  40.     UBYTE    DialPrefix[80];
  41.     UBYTE    DialSuffix[80];
  42.  
  43.     UBYTE    NoCarrier[16];
  44.     UBYTE    NoDialTone[16];
  45.     UBYTE    Connect[16];
  46.     UBYTE    Voice[16];
  47.     UBYTE    Ring[16];
  48.     UBYTE    Busy[16];
  49.  
  50.     LONG    RedialDelay;
  51.     LONG    DialRetries;
  52.     LONG    DialTimeout;
  53.     BYTE    ConnectAutoBaud;
  54.     BYTE    DropDTR;
  55. };
  56.  
  57. struct OldCommandSettings
  58. {
  59.     UBYTE    StartupMacro[256];
  60.     UBYTE    LogoffMacro[256];
  61.     UBYTE    UploadMacro[256];
  62.     UBYTE    DownloadMacro[256];
  63. };
  64.  
  65. struct OldScreenSettings
  66. {
  67.     ULONG    DisplayMode;
  68.     WORD    ColourMode;
  69.     UWORD    Colours[16];
  70.     UBYTE    FontName[256];
  71.     WORD    FontHeight;
  72.  
  73.     BYTE    MakeScreenPublic;
  74.     BYTE    ShanghaiWindows;
  75.  
  76.     BYTE    Blinking;
  77.     BYTE    FasterLayout;
  78.     BYTE    TitleBar;
  79.     BYTE    StatusLine;
  80. };
  81.  
  82. struct OldTerminalSettings
  83. {
  84.     BYTE    BellMode;
  85.     BYTE    AlertMode;
  86.     BYTE    EmulationMode;
  87.     BYTE    FontMode;
  88.  
  89.     BYTE    SendCR;
  90.     BYTE    SendLF;
  91.     BYTE    ReceiveCR;
  92.     BYTE    ReceiveLF;
  93.  
  94.     UWORD    NumColumns,
  95.         NumLines;
  96.  
  97.     UBYTE    KeyMapFileName[256];
  98.     UBYTE    EmulationFileName[256];
  99.     UBYTE    BeepFileName[256];
  100.  
  101.     UBYTE    TextFontName[256];
  102.     WORD    TextFontHeight;
  103. };
  104.  
  105. struct OldPathSettings
  106. {
  107.     UBYTE    ASCIIUploadPath[256];
  108.     UBYTE    ASCIIDownloadPath[256];
  109.  
  110.     UBYTE    TextUploadPath[256];
  111.     UBYTE    TextDownloadPath[256];
  112.  
  113.     UBYTE    BinaryUploadPath[256];
  114.     UBYTE    BinaryDownloadPath[256];
  115.  
  116.     UBYTE    DefaultStorage[256];
  117.  
  118.     UBYTE    Editor[256];
  119. };
  120.  
  121. struct OldMiscSettings
  122. {
  123.     BYTE    Priority;
  124.     BYTE    BackupConfig;
  125.  
  126.     BYTE    OpenFastMacroPanel;
  127.     BYTE    ReleaseDevice;
  128.  
  129.     BYTE    TransferServer;
  130.     BYTE    EmulationServer;
  131.  
  132.     BYTE    OverridePath;
  133.     BYTE    AutoUpload;
  134.     BYTE    SetArchivedBit;
  135.     BYTE    IdentifyFiles;
  136. };
  137.  
  138. struct OldClipSettings
  139. {
  140.     WORD    ClipboardUnit;
  141.  
  142.     WORD    LineDelay,
  143.         CharDelay;
  144.  
  145.     UBYTE    InsertPrefix[80];
  146.     UBYTE    InsertSuffix[80];
  147. };
  148.  
  149. struct OldCaptureSettings
  150. {
  151.     BYTE    LogActions;
  152.     BYTE    LogCall;
  153.     UBYTE    LogFileName[256];
  154.  
  155.     LONG    MaxBufferSize;
  156.     BYTE    BufferEnabled;
  157.  
  158.     BYTE    ConnectAutoCapture;
  159.     BYTE    CaptureFilterMode;
  160.     UBYTE    CapturePath[256];
  161. };
  162.  
  163. struct OldFileSettings
  164. {
  165.     UBYTE    ProtocolFileName[256];
  166.     UBYTE    TranslationFileName[256];
  167.     UBYTE    MacroFileName[256];
  168.     UBYTE    CursorFileName[256];
  169.     UBYTE    FastMacroFileName[256];
  170. };
  171.  
  172. struct OldEmulationSettings
  173. {
  174.     BYTE    CursorMode;
  175.     BYTE    NumericMode;
  176.  
  177.     BYTE    CursorWrap;
  178.     BYTE    LineWrap;
  179.  
  180.     BYTE    InsertMode;
  181.     BYTE    NewLineMode;
  182.  
  183.     BYTE    FontScale;
  184.     BYTE    ScrollMode;
  185.     BYTE    DestructiveBackspace;
  186.     BYTE    SwapBSDelete;
  187.     BYTE    PrinterEnabled;
  188.     BYTE    Pad;
  189.  
  190.     UBYTE    AnswerBack[80];
  191. };
  192.  
  193. struct OldConfiguration
  194. {
  195.     struct OldSerialSettings    SerialConfig;
  196.     struct OldModemSettings        ModemConfig;
  197.     struct OldScreenSettings    ScreenConfig;
  198.     struct OldTerminalSettings    TerminalConfig;
  199.     struct OldEmulationSettings    EmulationConfig;
  200.     struct OldClipSettings        ClipConfig;
  201.     struct OldCaptureSettings    CaptureConfig;
  202.     struct OldCommandSettings    CommandConfig;
  203.     struct OldMiscSettings        MiscConfig;
  204.     struct OldPathSettings        PathConfig;
  205.     struct OldFileSettings        FileConfig;
  206. };
  207.  
  208. struct OldPhoneHeader
  209. {
  210.     UBYTE    Name[40],        /* BBS name. */
  211.         Number[60],        /* Phone number. */
  212.         Comment[40];        /* Comment. */
  213.  
  214.     UBYTE    UserName[30],        /* User name for this BSS. */
  215.         Password[30];        /* Password for user name. */
  216. };
  217.  
  218.     /* ConvertHeader():
  219.      *
  220.      *    Convert old style phone book header to new style
  221.      *    phone book header.
  222.      */
  223.  
  224. STATIC VOID __regargs
  225. ConvertHeader(struct OldPhoneHeader *OldHeader,struct PhoneHeader *NewHeader)
  226. {
  227.     strcpy(NewHeader -> Name,    OldHeader -> Name);
  228.     strcpy(NewHeader -> Number,    OldHeader -> Number);
  229.     strcpy(NewHeader -> Comment,    OldHeader -> Comment);
  230.  
  231.     strcpy(NewHeader -> UserName,    OldHeader -> UserName);
  232.     strcpy(NewHeader -> Password,    OldHeader -> Password);
  233. }
  234.  
  235.     /* ConvertConfig():
  236.      *
  237.      *    Convert old style configuration to new style configuration.
  238.      */
  239.  
  240. STATIC BYTE __regargs
  241. ConvertConfig(struct OldConfiguration *OldConfig,struct Configuration *NewConfig,BOOLEAN IsPhonebook)
  242. {
  243.     if(CreateConfigEntry(NewConfig,PREF_SERIAL))
  244.     {
  245.         ResetConfigEntry(NewConfig,PREF_SERIAL,FALSE);
  246.  
  247.         memcpy(NewConfig -> SerialConfig,&OldConfig -> SerialConfig,MIN(sizeof(struct SerialSettings),sizeof(struct OldSerialSettings)));
  248.  
  249.         FixOldConfig(NewConfig,PREF_SERIAL,IsPhonebook,2,4);
  250.     }
  251.     else
  252.         return(FALSE);
  253.  
  254.     if(CreateConfigEntry(NewConfig,PREF_MODEM))
  255.     {
  256.         ResetConfigEntry(NewConfig,PREF_MODEM,FALSE);
  257.  
  258.         memcpy(NewConfig -> ModemConfig,&OldConfig -> ModemConfig,MIN(sizeof(struct ModemSettings),sizeof(struct OldModemSettings)));
  259.  
  260.         FixOldConfig(NewConfig,PREF_MODEM,IsPhonebook,2,4);
  261.     }
  262.     else
  263.         return(FALSE);
  264.  
  265.     if(CreateConfigEntry(NewConfig,PREF_COMMAND))
  266.     {
  267.         ResetConfigEntry(NewConfig,PREF_COMMAND,FALSE);
  268.  
  269.         memcpy(NewConfig -> CommandConfig,&OldConfig -> CommandConfig,MIN(sizeof(struct CommandSettings),sizeof(struct OldCommandSettings)));
  270.  
  271.         FixOldConfig(NewConfig,PREF_COMMAND,IsPhonebook,2,4);
  272.     }
  273.     else
  274.         return(FALSE);
  275.  
  276.     if(CreateConfigEntry(NewConfig,PREF_SCREEN))
  277.     {
  278.         ResetConfigEntry(NewConfig,PREF_SCREEN,FALSE);
  279.  
  280.         memcpy(NewConfig -> ScreenConfig,&OldConfig -> ScreenConfig,MIN(sizeof(struct ScreenSettings),sizeof(struct OldScreenSettings)));
  281.  
  282.         FixOldConfig(NewConfig,PREF_SCREEN,IsPhonebook,2,4);
  283.     }
  284.     else
  285.         return(FALSE);
  286.  
  287.     if(CreateConfigEntry(NewConfig,PREF_TERMINAL))
  288.     {
  289.         ResetConfigEntry(NewConfig,PREF_TERMINAL,FALSE);
  290.  
  291.         memcpy(NewConfig -> TerminalConfig,&OldConfig -> TerminalConfig,MIN(sizeof(struct TerminalSettings),sizeof(struct OldTerminalSettings)));
  292.  
  293.         FixOldConfig(NewConfig,PREF_TERMINAL,IsPhonebook,2,4);
  294.     }
  295.     else
  296.         return(FALSE);
  297.  
  298.     if(CreateConfigEntry(NewConfig,PREF_PATH))
  299.     {
  300.         ResetConfigEntry(NewConfig,PREF_PATH,FALSE);
  301.  
  302.         memcpy(NewConfig -> PathConfig,&OldConfig -> PathConfig,MIN(sizeof(struct PathSettings),sizeof(struct OldPathSettings)));
  303.  
  304.         FixOldConfig(NewConfig,PREF_PATH,IsPhonebook,2,4);
  305.     }
  306.     else
  307.         return(FALSE);
  308.  
  309.     if(CreateConfigEntry(NewConfig,PREF_MISC))
  310.     {
  311.         ResetConfigEntry(NewConfig,PREF_MISC,FALSE);
  312.  
  313.         memcpy(NewConfig -> MiscConfig,&OldConfig -> MiscConfig,MIN(sizeof(struct MiscSettings),sizeof(struct OldMiscSettings)));
  314.  
  315.         FixOldConfig(NewConfig,PREF_MISC,IsPhonebook,2,4);
  316.     }
  317.     else
  318.         return(FALSE);
  319.  
  320.     if(CreateConfigEntry(NewConfig,PREF_CLIP))
  321.     {
  322.         ResetConfigEntry(NewConfig,PREF_CLIP,FALSE);
  323.  
  324.         memcpy(NewConfig -> ClipConfig,&OldConfig -> ClipConfig,MIN(sizeof(struct ClipSettings),sizeof(struct OldClipSettings)));
  325.  
  326.         FixOldConfig(NewConfig,PREF_CLIP,IsPhonebook,2,4);
  327.     }
  328.     else
  329.         return(FALSE);
  330.  
  331.     if(CreateConfigEntry(NewConfig,PREF_CAPTURE))
  332.     {
  333.         ResetConfigEntry(NewConfig,PREF_CAPTURE,FALSE);
  334.  
  335.         memcpy(NewConfig -> CaptureConfig,&OldConfig -> CaptureConfig,MIN(sizeof(struct CaptureSettings),sizeof(struct OldCaptureSettings)));
  336.  
  337.         strcpy(NewConfig -> CaptureConfig -> CallLogFileName,NewConfig -> CaptureConfig -> LogFileName);
  338.  
  339.         AddPart(NewConfig -> CaptureConfig -> CallLogFileName,"term-call.log",MAX_FILENAME_LENGTH);
  340.  
  341.         FixOldConfig(NewConfig,PREF_CAPTURE,IsPhonebook,2,4);
  342.     }
  343.     else
  344.         return(FALSE);
  345.  
  346.     if(CreateConfigEntry(NewConfig,PREF_FILE))
  347.     {
  348.         ResetConfigEntry(NewConfig,PREF_FILE,FALSE);
  349.  
  350.         memcpy(NewConfig -> FileConfig,&OldConfig -> FileConfig,MIN(sizeof(struct FileSettings),sizeof(struct OldFileSettings)));
  351.  
  352.         FixOldConfig(NewConfig,PREF_FILE,IsPhonebook,2,4);
  353.     }
  354.     else
  355.         return(FALSE);
  356.  
  357.     if(CreateConfigEntry(NewConfig,PREF_EMULATION))
  358.     {
  359.         ResetConfigEntry(NewConfig,PREF_EMULATION,FALSE);
  360.  
  361.         memcpy(NewConfig -> EmulationConfig,&OldConfig -> EmulationConfig,MIN(sizeof(struct EmulationSettings),sizeof(struct OldEmulationSettings)));
  362.  
  363.         FixOldConfig(NewConfig,PREF_EMULATION,IsPhonebook,2,4);
  364.     }
  365.     else
  366.         return(FALSE);
  367.  
  368.     FinalFix(NewConfig,IsPhonebook,2,4);
  369.  
  370.     return(TRUE);
  371. }
  372.  
  373.     /* LoadOldPhonebook(STRPTR Name):
  374.      *
  375.      *    Restore a phone book from a disk file.
  376.      */
  377.  
  378. BYTE __regargs
  379. LoadOldPhonebook(STRPTR Name)
  380. {
  381.     STATIC ULONG Stops[6 * 2] =
  382.     {
  383.         ID_TERM,ID_VERS,
  384.         ID_TERM,ID_DIAL,
  385.         ID_TERM,ID_PREF,
  386.         ID_TERM,ID_DATE,
  387.         ID_TERM,ID_PHON,
  388.         ID_TERM,ID_PSWD
  389.     };
  390.  
  391.     struct PhoneEntry    **PrivatePhonebook;
  392.     LONG             PrivatePhoneSize = 0;
  393.     LONG             Size = 0,Count = 0,Last = -1;
  394.     struct IFFHandle    *Handle;
  395.     BYTE             Success = FALSE;
  396.     struct ContextNode    *Chunk;
  397.     BYTE             LastHadTime    = TRUE,
  398.                  HadPassword    = FALSE;
  399.     struct TimeDateNode    *TimeDateNode;
  400.     struct OldConfiguration    *OldConfig;
  401.     struct OldPhoneHeader    *OldHeader;
  402.     LONG             Error = 0;
  403.  
  404.     if(OldConfig = (struct OldConfiguration *)AllocVecPooled(sizeof(struct OldConfiguration) + sizeof(struct OldPhoneHeader),MEMF_ANY))
  405.     {
  406.         OldHeader = (struct OldPhoneHeader *)(OldConfig + 1);
  407.  
  408.         if(Handle = AllocIFF())
  409.         {
  410.             if(Handle -> iff_Stream = Open(Name,MODE_OLDFILE))
  411.             {
  412.                 InitIFFasDOS(Handle);
  413.  
  414.                 if(!(Error = OpenIFF(Handle,IFFF_READ)))
  415.                 {
  416.                     if(!(Error = StopChunks(Handle,(LONG *)Stops,6)))
  417.                     {
  418.                         while(!ParseIFF(Handle,IFFPARSE_SCAN))
  419.                         {
  420.                             Chunk = CurrentChunk(Handle);
  421.  
  422.                             if(Chunk -> cn_ID == ID_VERS)
  423.                             {
  424.                                 struct TermInfo TermInfo;
  425.  
  426.                                 if(ReadChunkBytes(Handle,&TermInfo,sizeof(struct TermInfo)) == sizeof(struct TermInfo))
  427.                                 {
  428.                                     if(TermInfo . Version != 2 || TermInfo . Revision != 4)
  429.                                     {
  430.                                         Error = ERR_OUTDATED;
  431.  
  432.                                         break;
  433.                                     }
  434.                                 }
  435.                                 else
  436.                                 {
  437.                                     Error = IoErr();
  438.  
  439.                                     break;
  440.                                 }
  441.                             }
  442.  
  443.                             if(Chunk -> cn_ID == ID_PSWD)
  444.                             {
  445.                                 UBYTE DummyBuffer[20];
  446.  
  447.                                 HadPassword = TRUE;
  448.  
  449.                                 if(ReadChunkBytes(Handle,DummyBuffer,20) == 20)
  450.                                 {
  451.                                     if(PhonePasswordUsed)
  452.                                     {
  453.                                         if(!memcmp(PhonePassword,DummyBuffer,20))
  454.                                             continue;
  455.                                     }
  456.  
  457.                                     memset(SharedBuffer,0,21);
  458.  
  459.                                     if(GetString(FALSE,TRUE,21,LocaleString(MSG_PHONEPANEL_PLEASE_ENTER_PASSWORD_TXT),SharedBuffer))
  460.                                     {
  461.                                         UBYTE AnotherBuffer[20];
  462.  
  463.                                         Encrypt(SharedBuffer,20,AnotherBuffer,SharedBuffer,strlen(SharedBuffer));
  464.  
  465.                                         if(!memcmp(DummyBuffer,AnotherBuffer,20))
  466.                                         {
  467.                                             memcpy(PhonePassword,DummyBuffer,20);
  468.  
  469.                                             PhonePasswordUsed = TRUE;
  470.  
  471.                                             continue;
  472.                                         }
  473.                                         else
  474.                                         {
  475.                                             MyEasyRequest(Window,LocaleString(MSG_TERMPHONE_WRONG_PASSWORD_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),Name);
  476.  
  477.                                             break;
  478.                                         }
  479.                                     }
  480.                                     else
  481.                                         break;
  482.                                 }
  483.                                 else
  484.                                 {
  485.                                     Error = IoErr();
  486.  
  487.                                     break;
  488.                                 }
  489.                             }
  490.  
  491.                             if(Chunk -> cn_ID == ID_DIAL)
  492.                             {
  493.                                 if(ReadChunkBytes(Handle,&Size,sizeof(LONG)) == sizeof(LONG))
  494.                                 {
  495.                                     if(!(PrivatePhonebook = CreatePhonebook(Size,&PrivatePhoneSize,TRUE)))
  496.                                         break;
  497.                                 }
  498.                                 else
  499.                                 {
  500.                                     Error = IoErr();
  501.  
  502.                                     break;
  503.                                 }
  504.                             }
  505.  
  506.                             if(Chunk -> cn_ID == ID_PHON)
  507.                             {
  508.                                 WORD Size = MIN(sizeof(struct OldPhoneHeader),Chunk -> cn_Size);
  509.  
  510.                                 if(ReadChunkBytes(Handle,OldHeader,Size) == Size)
  511.                                 {
  512.                                     if(PhonePasswordUsed)
  513.                                         Decrypt((UBYTE *)OldHeader,Size,(UBYTE *)OldHeader,PhonePassword,20);
  514.                                 }
  515.                                 else
  516.                                 {
  517.                                     Error = IoErr();
  518.  
  519.                                     break;
  520.                                 }
  521.                             }
  522.  
  523.                             if(Chunk -> cn_ID == ID_PREF)
  524.                             {
  525.                                 if(Last != -1)
  526.                                 {
  527.                                     if(!LastHadTime)
  528.                                     {
  529.                                         if(TimeDateNode = CreateTimeDateNode(-1,-1,"",2))
  530.                                             AddTail((struct List *)&PrivatePhonebook[Last] -> TimeDateList,&TimeDateNode -> VanillaNode);
  531.                                     }
  532.                                 }
  533.  
  534.                                 if(Size && Count < Size)
  535.                                 {
  536.                                     WORD LastSize = MIN(Chunk -> cn_Size,sizeof(struct OldConfiguration));
  537.  
  538.                                     PhonePasswordUsed = HadPassword;
  539.  
  540.                                     if(ReadChunkBytes(Handle,OldConfig,LastSize) == LastSize)
  541.                                     {
  542.                                         if(PhonePasswordUsed)
  543.                                             Decrypt((UBYTE *)OldConfig,LastSize,(UBYTE *)OldConfig,PhonePassword,20);
  544.  
  545.                                         if(ConvertConfig(OldConfig,PrivatePhonebook[Count] -> Config,TRUE))
  546.                                         {
  547.                                             ConvertHeader(OldHeader,PrivatePhonebook[Count] -> Header);
  548.  
  549.                                             Last = Count;
  550.  
  551.                                             PrivatePhonebook[Count] -> Count = -1;
  552.  
  553.                                             Count++;
  554.  
  555.                                             LastHadTime = FALSE;
  556.                                         }
  557.                                         else
  558.                                         {
  559.                                             if(Count)
  560.                                                 Size = Count - 1;
  561.                                             else
  562.                                                 Size = 0;
  563.  
  564.                                             break;
  565.                                         }
  566.                                     }
  567.                                     else
  568.                                     {
  569.                                         Error = IoErr();
  570.  
  571.                                         if(Count)
  572.                                             Size = Count - 1;
  573.                                         else
  574.                                             Size = 0;
  575.  
  576.                                         break;
  577.                                     }
  578.                                 }
  579.                             }
  580.  
  581.                             if(Chunk -> cn_ID == ID_DATE)
  582.                             {
  583.                                 if(Last != -1)
  584.                                 {
  585.                                     WORD Count = (Chunk -> cn_Size - sizeof(struct TimeDateHeader)) / sizeof(struct TimeDate);
  586.  
  587.                                     if(TimeDateNode = CreateTimeDateNode(-1,-1,"",Count))
  588.                                     {
  589.                                         if(ReadChunkBytes(Handle,&TimeDateNode -> Header,sizeof(struct TimeDateHeader)) == sizeof(struct TimeDateHeader))
  590.                                         {
  591.                                             if(ReadChunkBytes(Handle,TimeDateNode -> Table,sizeof(struct TimeDate) * Count) == sizeof(struct TimeDate) * Count)
  592.                                             {
  593.                                                 AdaptTimeDateNode(TimeDateNode);
  594.  
  595.                                                 AddTail((struct List *)&PrivatePhonebook[Last] -> TimeDateList,&TimeDateNode -> VanillaNode);
  596.  
  597.                                                 LastHadTime = TRUE;
  598.                                             }
  599.                                             else
  600.                                             {
  601.                                                 Error = IoErr();
  602.  
  603.                                                 FreeTimeDateNode(TimeDateNode);
  604.                                             }
  605.                                         }
  606.                                         else
  607.                                         {
  608.                                             Error = IoErr();
  609.  
  610.                                             FreeTimeDateNode(TimeDateNode);
  611.                                         }
  612.                                     }
  613.                                 }
  614.                             }
  615.                         }
  616.  
  617.                         if(Size)
  618.                         {
  619.                             if(!LastHadTime && Last != -1)
  620.                             {
  621.                                 if(TimeDateNode = CreateTimeDateNode(-1,-1,"",2))
  622.                                     AddTail((struct List *)&PrivatePhonebook[Last] -> TimeDateList,&TimeDateNode -> VanillaNode);
  623.                             }
  624.  
  625.                             if(Phonebook)
  626.                                 DeletePhonebook(Phonebook,PhoneSize,TRUE);
  627.  
  628.                             Phonebook = PrivatePhonebook;
  629.                             PhoneSize = PrivatePhoneSize;
  630.  
  631.                             NumPhoneEntries = Size;
  632.  
  633.                             Success = TRUE;
  634.                         }
  635.                         else
  636.                         {
  637.                             if(PrivatePhoneSize)
  638.                             {
  639.                                 DeletePhonebook(PrivatePhonebook,PrivatePhoneSize,TRUE);
  640.  
  641.                                 Success = FALSE;
  642.                             }
  643.                         }
  644.  
  645.                         FreeDialList(TRUE);
  646.                     }
  647.  
  648.                     CloseIFF(Handle);
  649.                 }
  650.  
  651.                 Close(Handle -> iff_Stream);
  652.             }
  653.             else
  654.                 Error = IoErr();
  655.  
  656.             FreeIFF(Handle);
  657.         }
  658.         else
  659.             Error = ERR_NO_MEM;
  660.  
  661.         FreeVecPooled(OldConfig);
  662.     }
  663.     else
  664.         Error = ERR_NO_MEM;
  665.  
  666.     if(Error)
  667.         SetIoErr(Error);
  668.  
  669.     return(Success);
  670. }
  671.  
  672.     /* ReadConfig(STRPTR Name,struct Configuration *Config):
  673.      *
  674.      *    Read the configuration file, very much the same as ReadIFFData().
  675.      */
  676.  
  677. BYTE __regargs
  678. ReadOldConfig(STRPTR Name,struct Configuration *Config)
  679. {
  680.     struct IFFHandle    *Handle;
  681.     BYTE             Success = FALSE;
  682.     struct StoredProperty    *Prop;
  683.     struct TermInfo        *TermInfo;
  684.     struct OldConfiguration    *OldConfig;
  685.     LONG             Error = 0;
  686.  
  687.     if(OldConfig = (struct OldConfiguration *)AllocVecPooled(sizeof(struct OldConfiguration),MEMF_ANY))
  688.     {
  689.         if(Handle = AllocIFF())
  690.         {
  691.             if(Handle -> iff_Stream = Open(Name,MODE_OLDFILE))
  692.             {
  693.                 InitIFFasDOS(Handle);
  694.  
  695.                 if(!(Error = OpenIFF(Handle,IFFF_READ)))
  696.                 {
  697.                     if(!(Error = PropChunks(Handle,(LONG *)VersionProps,1)))
  698.                     {
  699.                         if(!(Error = StopChunk(Handle,ID_TERM,ID_PREF)))
  700.                         {
  701.                             if(!ParseIFF(Handle,IFFPARSE_SCAN))
  702.                             {
  703.                                 if(Prop = FindProp(Handle,ID_TERM,ID_VERS))
  704.                                 {
  705.                                     TermInfo = (struct TermInfo *)Prop -> sp_Data;
  706.  
  707.                                     if(TermInfo -> Version == 2 && TermInfo -> Revision == 4)
  708.                                     {
  709.                                         struct ContextNode *Chunk = CurrentChunk(Handle);
  710.  
  711.                                         if(ReadChunkRecords(Handle,OldConfig,MIN(Chunk -> cn_Size,sizeof(struct OldConfiguration)),1) == 1)
  712.                                         {
  713.                                             if(ConvertConfig(OldConfig,Config,FALSE))
  714.                                                 Success = TRUE;
  715.                                         }
  716.                                         else
  717.                                             Error = IoErr();
  718.                                     }
  719.                                     else
  720.                                         Error = ERR_OUTDATED;
  721.                                 }
  722.                             }
  723.                         }
  724.                     }
  725.  
  726.                     CloseIFF(Handle);
  727.                 }
  728.  
  729.                 Close(Handle -> iff_Stream);
  730.             }
  731.             else
  732.                 Error = IoErr();
  733.  
  734.             FreeIFF(Handle);
  735.         }
  736.         else
  737.             Error = ERR_NO_MEM;
  738.  
  739.         FreeVecPooled(OldConfig);
  740.     }
  741.     else
  742.         Error = ERR_NO_MEM;
  743.  
  744.     if(Error)
  745.         SetIoErr(Error);
  746.  
  747.     return(Success);
  748. }
  749.